package com.unismc.charge.collector.scheduler;

import com.unismc.charge.collector.service.QueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author: Forward Seen
 * @description:
 * @createTime: 2024/4/29 10:41
 * @since: 1.0
 */
@Slf4j
@Component
public class QueryScheduler {
    @Resource
    private QueryService queryService;

    @Scheduled(fixedRate = 4 * 60 * 60 * 1000)
    public void scheduleQueryStationsStatus() {
        log.info("scheduleQueryStationsStatus 定时查询设备接口状态 查询时间：{}", LocalDateTime.now());
        queryService.queryStationsStatus();
    }

    /**
     * 每天0:00查询前一天的统计信息
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void scheduleQueryStationStats() {
        log.info("scheduleQueryStationStats 定时查询统计信息 查询时间：{}", LocalDateTime.now());
        queryService.queryStationsStats();
    }
}
